﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _4591BRD
{
    [Serializable]
    class CharDataObj
    {
        private int _CharID = 0;
        public int CharID
        {
            get { return _CharID; }
            set { _CharID = value; }
        }

        private int _PointRankDaily = 0;
        public int PointRankDaily
        {
            get { return _PointRankDaily; }
            set { _PointRankDaily = value; }
        }
        private int _PointRankMonthly = 0;
        public int PointRankMonthly
        {
            get { return _PointRankMonthly; }
            set { _PointRankMonthly = value; }
        }
        private int _KillRankDaily = 0;
        public int KillRankDaily
        {
            get { return _KillRankDaily; }
            set { _KillRankDaily = value; }
        }
        private int _KillRankMonthly = 0;
        public int KillRankMonthly
        {
            get { return _KillRankMonthly; }
            set { _KillRankMonthly = value; }
        }

        //角色排名
        private Dictionary<string, int> _RankData = new Dictionary<string, int>();
        public Dictionary<string, int> RankData
        {
            get { return _RankData; }
        }

        public void SetRankValue(string key, int value)
        {
            lock (_RankData)
            {
                if (!_RankData.ContainsKey(key))
                    _RankData.Add(key, value);
                else
                    _RankData[key] = value;
            }
        }

        public int GetRankValue(string key)
        {
            lock (_RankData)
            {
                if (!_RankData.ContainsKey(key))
                    _RankData.Add(key, 0);
                return _RankData[key];
            }
        }

        //基本战斗数据
        private Dictionary<string, int> _ObjData = new Dictionary<string, int>();
        public Dictionary<string, int> ObjData
        {
            get { return _ObjData; }
        }

        public void AddDataValue(string key, int value)
        {
            lock (_ObjData)
            {
                if (!_ObjData.ContainsKey(key))
                    _ObjData.Add(key, value);
                else
                    _ObjData[key] += value;
            }
        }

        public int GetDataValue(string key)
        {
            lock (_ObjData)
            {
                if (!_ObjData.ContainsKey(key))
                    _ObjData.Add(key, 0);
                return _ObjData[key];
            }
        }

        //击杀目标角色次数
        private Dictionary<int, int> _KillObj = new Dictionary<int, int>();
        public Dictionary<int, int> KillObj
        {
            get { return _KillObj; }
        }

        public void AddKillObjValue(int key, int value)
        {
            lock (_KillObj)
            {
                if (!_KillObj.ContainsKey(key))
                    _KillObj.Add(key, value);
                else
                    _KillObj[key] += value;
            }
        }

        public int GetKillObjValue(int key)
        {
            lock (_KillObj)
            {
                if (!_KillObj.ContainsKey(key))
                    _KillObj.Add(key, 0);
                return _KillObj[key];
            }
        }

        //使用武器击杀次数
        private Dictionary<int, int> _WeaponKill = new Dictionary<int, int>();
        public Dictionary<int, int> WeaponKill
        {
            get { return _WeaponKill; }
        }

        public void AddWeaponKillValue(int key, int value)
        {
            lock (_WeaponKill)
            {
                if (!_WeaponKill.ContainsKey(key))
                    _WeaponKill.Add(key, value);
                else
                    _WeaponKill[key] += value;
            }
        }

        public int GetWeaponKillValue(int key)
        {
            lock (_WeaponKill)
            {
                if (!_WeaponKill.ContainsKey(key))
                    _WeaponKill.Add(key, 0);
                return _WeaponKill[key];
            }
        }

        public struct UseHit
        {
            public int UseCount;
            public int HitCount;
        }

        //使用武器命中率
        private Dictionary<int, UseHit> _WeaponUse = new Dictionary<int, UseHit>();
        public Dictionary<int, UseHit> WeaponUse
        {
            get { return _WeaponUse; }
        }

        public void AddWeaponUseValue(int key, int use, int hit)
        {
            lock (_WeaponUse)
            {
                UseHit tmp;
                if (!_WeaponUse.ContainsKey(key))
                {
                    tmp = new UseHit();
                    tmp.UseCount = use;
                    tmp.HitCount = hit;
                }
                else
                {
                    tmp = _WeaponUse[key];
                    tmp.UseCount += use;
                    tmp.HitCount += hit;
                    _WeaponUse.Remove(key);
                }
                _WeaponUse.Add(key, tmp);
            }
        }

        public UseHit GetWeaponUseValue(int key)
        {
            lock (_WeaponUse)
            {
                if (!_WeaponUse.ContainsKey(key))
                {
                    UseHit tmp = new UseHit();
                    _WeaponUse.Add(key, tmp);
                }
                return _WeaponUse[key];
            }
        }
        
        //使用道具
        private Dictionary<int, int> _EquipUse = new Dictionary<int, int>();
        public Dictionary<int, int> EquipUse
        {
            get { return _EquipUse; }
        }

        public void AddEquipUseValue(int key, int value)
        {
            lock (_EquipUse)
            {
                if (!_EquipUse.ContainsKey(key))
                    _EquipUse.Add(key, value);
                else
                    _EquipUse[key] += value;
            }
        }

        public int GetEquipUseValue(int key)
        {
            lock (_EquipUse)
            {
                if (!_EquipUse.ContainsKey(key))
                {
                    _EquipUse.Add(key, 0);
                }
                return _EquipUse[key];
            }
        }
    }
}
